<?php
/**
 * Oryx Render Libary 
 * @version 0.3
 * @author Richard Adams
 */
class Oryx {
	
	/**
	 * Class Constructor
	 * @return 
	 */
	public function __construct()
	{
		$this->CI =& get_instance();
	}
	
	/**
	 * Renders all the views e.g. header, content , footer
	 * @return 
	 * @param string $view_name The name of the view to use for the content section 
	 * @param string $data[optional] The data to Pass to the view 
	 * @param string $render_case[optional] the type of view to use e.g. admin 
	 */
	public function render($view_name, $data = null , $render_case = null)
    {	
		$this->CI->load->library('user_agent');
		
		if ($render_case == 'admin')
		{
		    if ($this->CI->agent->is_mobile())
			{
				$render_case = "admin_iphone";
			}
		}
		
		switch ($render_case) {
			case 'admin':
				$view = 'admin/content/'.$view_name;
				$data['title'] = '*Oryx';
				$this->CI->load->view('admin/site/header',$data);
				$this->CI->load->view($view, $data);
				$this->CI->load->view('admin/site/footer');
			break;
				
			case 'client':
				$view = 'client/content/'.$view_name;
				$data['title'] = '*Oryx';
				$this->CI->load->view('admin/site/header',$data);
				$this->CI->load->view($view, $data);
				$this->CI->load->view('admin/site/footer');

			break;
			
			case 'admin_iphone':
				$view = 'admin/content/'.$view_name;
				$data['title'] = $this->CI->agent->mobile();
				$this->CI->load->view('header',$data);
				$this->CI->load->view($view, $data);
				$this->CI->load->view('footer');
			break;
			
			default:
				$view = 'content/'.$view_name;
				$data['title'] = '*Oryx default';
				$this->CI->load->view('header',$data);
				$this->CI->load->view($view, $data);
				$this->CI->load->view('footer');
			break;
		}
    }
}